﻿SET SQL DIALECT 3;

SET NAMES NONE;

CREATE TABLE TOBJECT (
	ID         INTEGER NOT NULL,
    EXT_ID     INTEGER,
    PARENT_ID  INTEGER,
    CLASS_ID   INTEGER,
    NAME       VARCHAR(100) 
    
);

ALTER TABLE TOBJECT ADD PRIMARY KEY (ID);
---------------------------------
SET SQL DIALECT 3;

SET NAMES NONE;

CREATE TABLE TCLASSES (
    ID         INTEGER NOT NULL,
    NAME     VARCHAR(250),
    GROUP_NAME  VARCHAR(250),
    FORM   VARCHAR(250)
);

ALTER TABLE TCLASSES ADD PRIMARY KEY (ID);

--------------------
SET SQL DIALECT 3;

SET NAMES NONE;

CREATE TABLE TPROCESSES (
    ID         INTEGER NOT NULL,
    CLASS_ID     INTEGER NOT NULL,
    NAME  VARCHAR(250),
    FORM   VARCHAR(250)
);

ALTER TABLE TPROCESSES ADD PRIMARY KEY (ID);
-----------------------------
SET SQL DIALECT 3;

SET NAMES NONE;

CREATE TABLE TRULE_INSERT (
    ID         INTEGER NOT NULL,
    CLASS_ID     INTEGER NOT NULL,
    CHILD_ID  INTEGER NOT NULL
);

ALTER TABLE TRULE_INSERT ADD PRIMARY KEY (ID);

--------------------------------

SET SQL DIALECT 3;

SET NAMES NONE;

CREATE TABLE DIVISION (
    ID  INTEGER NOT NULL,
    BOSS_ID   INTEGER,
    DATE_CREATED     DATE,
    DESCRIPTION     VARCHAR(200)
);

ALTER TABLE DIVISION ADD PRIMARY KEY (ID);

--------------------------

SET SQL DIALECT 3;

SET NAMES NONE;

CREATE TABLE SERVICE_DIVISION (
    ID  INTEGER NOT NULL,
    ROOM_ID   INTEGER,  
    TELEPHONE    VARCHAR(100)
);

ALTER TABLE SERVICE_DIVISION ADD PRIMARY KEY (ID);
------------------------
SET SQL DIALECT 3;

SET NAMES NONE;

CREATE TABLE ORGANIZATIONAL_DIVISION (
    ID  INTEGER NOT NULL,
    SLOGAN  VARCHAR(100),  
    EMAIL    VARCHAR(100)
);

ALTER TABLE ORGANIZATIONAL_DIVISION ADD PRIMARY KEY (ID);
--------------------------------------

SET SQL DIALECT 3;

SET NAMES NONE;

CREATE TABLE MANAGING_DIVISION (
    ID  INTEGER NOT NULL,
    SUBSTITUTE_ID  INTEGER,
    SUBORDERED_DIVISION_ID   INTEGER
);

ALTER TABLE MANAGING_DIVISION ADD PRIMARY KEY (ID);
------------------------------------
SET SQL DIALECT 3;

SET NAMES NONE;

CREATE TABLE CLUB (
    ID  INTEGER NOT NULL,
    ROOM_ID  INTEGER,  
    SPECIALITY   VARCHAR(200)
);

ALTER TABLE CLUB ADD PRIMARY KEY (ID);

--------------------------------
SET SQL DIALECT 3;

SET NAMES NONE;

CREATE TABLE CLUB (
    ID  INTEGER NOT NULL,
    LOCATION_ID  [int] NULL,  
    TELEPHONE   VARCHAR(100)
);

ALTER TABLE CLUB ADD PRIMARY KEY (ID);
------------------------------

SET SQL DIALECT 3;

SET NAMES NONE;

CREATE TABLE SECTION (
    ID  INTEGER NOT NULL,
    LOCATION_ID  INTEGER,
    ROOM_ID  INTEGER,
    SCHEDULE   VARCHAR(500)
);

ALTER TABLE SECTION ADD PRIMARY KEY (ID);
------------------------------

